package com.bdqn.springweb.config;

import com.bdqn.springweb.config.filter.AuthorizationFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;

//@Configuration
public class FilterConfig {
    /**
     * 将自定义过滤器加入到过滤器链
     */
    @Bean
    public FilterRegistrationBean filterRegistrationBean(){
        FilterRegistrationBean registrationBean = new FilterRegistrationBean();
        registrationBean.setFilter(new AuthorizationFilter());
        registrationBean.setName("AuthorizationFilter");
        registrationBean.addUrlPatterns("/main");//作为演示，仅仅只限制/main访问
        registrationBean.setOrder(5);
        return registrationBean;
    }
}
